<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态创建节点</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <script>
        //创建div
        let div_ = document.createElement("div");
        div_.innerText = "box容器"
            //创建属性
        div_.setAttribute("class", "box")
            //追加body
        document.body.appendChild(div_)

        //创建P标签(节点)
        let p_ = document.createElement("p");
        p_.innerText = "段落标签"
        div_.appendChild(p_)
    </script>


</body>

</html>